import 'package:flutter/material.dart';
import 'package:flutterapp/src/bean/bean_art.dart';

class HomeArtListItemWidget extends StatefulWidget {
  final ArtModel artItem;
  HomeArtListItemWidget({this.artItem});
  @override
  _HomeArtListItemWidgetState createState() => _HomeArtListItemWidgetState();
}

class _HomeArtListItemWidgetState extends State<HomeArtListItemWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 200,
      padding: EdgeInsets.all(10),
      margin: EdgeInsets.only(bottom: 10),
      decoration: BoxDecoration(
        gradient: LinearGradient(colors: [Colors.grey[350], Colors.blue[100]]),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 标题
          Container(
            child: Text(
              "${widget.artItem.title}",
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
            ),
          ),
          SizedBox(height: 8),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Icon(
                Icons.pets_outlined,
                size: 16,
                color: Colors.black54,
              ),
              Text(
                "${widget.artItem.userId}",
                style: TextStyle(
                  fontSize: 16,
                  color: Colors.black54,
                ),
              ),
            ],
          ),
          SizedBox(height: 8),
          // 主题
          Expanded(
              child: Row(
            children: [
              Expanded(
                child: Container(
                  alignment: Alignment.topLeft,
                  child: Text(
                    "${widget.artItem.body}",
                    style: TextStyle(fontSize: 16),
                    maxLines: 4,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
              ),
              SizedBox(width: 20),
              Container(
                width: 150,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(10)),
                ),
                child: Image.asset("assets/images/app_icon.png",
                    fit: BoxFit.cover),
              ),
            ],
          )),
          // 底部
          Container(
              child: Row(children: [
            Text("120喜欢"),
            Container(
              width: 10,
              height: 10,
              margin: EdgeInsets.only(left: 5, right: 5),
              decoration: BoxDecoration(
                  color: Colors.blue,
                  borderRadius: BorderRadius.all(Radius.circular(5))),
            ),
            Text("10评论"),
          ]))
        ],
      ),
    );
  }
}
